package com.hbt.active_mq.my_active_mq;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.jms.Queue;
import javax.jms.Topic;

@RestController
public class MyController {
    @Autowired
    Queue queue;
    @Autowired
    Topic topic;

    @Autowired
    JmsMessagingTemplate template;


    @RequestMapping("/send/{msg}")
    public String sendMsg(@PathVariable("msg") String msg){
        template.convertAndSend(queue,msg);
        return "发送成功";
    }

    @RequestMapping("/sendTopic/{msg}")
    public String sendTopicMsg(@PathVariable("msg") String msg){
        template.convertAndSend(topic,msg);
        return "topic发送成功";
    }
}
